class QuizSummariesController < ApplicationController

  def show

    total_rounds = params['rn'].to_i

    incorrect_answers = params['ia'].split('~')

    incorrect_questions = []

    # Tried to use '$in' but that didn't return any
    # results so switching to a loop for now unfortunately
    incorrect_answers.each do |question_id|

        incorrect_questions <<
            Question.first({:_id => question_id})
    end

    num_correct_answers = total_rounds - incorrect_questions.length

    @quiz_summary = {
        :total_rounds => total_rounds,

        :incorrect_questions => incorrect_questions, 
            
        :score => ((num_correct_answers * 100)/total_rounds)
    }
  end
  
end
